package com.ttt.radioapp_core.helpers;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import ar.com.tristeslos3tigres.rssfeedreader.RssFeedItem;

import com.ttt.radioapp_core.activities.ListadoNoticiasActivity;
import com.ttt.radioapp_core.activities.NoticiaActivity;

public class Intents {
	public static class Alarm {
		public static final String BROADCAST_STOPMEDIA = "RadioStreamingService.StopMedia";
		
		private static Intent intent() {
			return new Intent(BROADCAST_STOPMEDIA);
		}

		public static PendingIntent pendingIntent(Context context,
				int flag) {
			return PendingIntent.getBroadcast(context.getApplicationContext(),
					0, intent(), flag);
		}

		public static PendingIntent pendingIntent(Context context) {
			PendingIntent pendingIntent = pendingIntent(context,
					PendingIntent.FLAG_UPDATE_CURRENT);

			return pendingIntent;
		}

		public static boolean isPendingIntentActive(Context context) {
			PendingIntent pendingIntent = pendingIntent(context,
					PendingIntent.FLAG_NO_CREATE);
			boolean alarmUp = pendingIntent != null;
			return alarmUp;
		}
		
	}
	public static class Noticias{
		public static Intent getListadoNoticiasIntent(Context context, String urlNoticias){
			Intent intent = new Intent();
			intent.setClass(context, ListadoNoticiasActivity.class);
			intent.putExtra(ListadoNoticiasActivity.URL_NEWS_FEED, urlNoticias);
			return intent;
		}
		
		public static Intent getNoticiasIntent(Context context, RssFeedItem noticia){
			Intent intent = new Intent();
			intent.setClass(context, NoticiaActivity.class);
			intent.putExtra(NoticiaActivity.INTENT_NOTICIA, noticia);
			return intent;
		}
	}
}
